<template>
    <!-- 物业项目 -->
    <div class="zs-table-page-container" v-loading="loading">
        <TableSearch @onSearch="search" :menuKey="menuKey" :pageKey="pageKey" :type="'2'">
        </TableSearch>
        <div class="zs-card zs-table-page-content">
            <el-table :data="tableData" class="zs-table-page-main" :stripe="stripe">
                <el-table-column label="序号" width="60" :align="'center'" fixed>
                    <template #default="scope">
                        {{ scope.$index + 1 + curPageSize * (currentPage - 1) }}
                        <!-- {{ scope.$index + 1 }} -->
                    </template>
                </el-table-column>
                <el-table-column prop="project_name" label="项目" :align="'left'" min-width="150"
                    :show-overflow-tooltip="true"></el-table-column>
                <el-table-column prop="business_format" label="业态" :align="'center'" min-width="120"></el-table-column>
                <el-table-column prop="stage" label="阶段" :align="'center'" min-width="120"></el-table-column>
                <el-table-column prop="groups" label="集团" :align="'center'"></el-table-column>
                <el-table-column prop="city" label="城市" :align="'center'"></el-table-column>
                <el-table-column prop="standardName" label="标准" :align="'center'"></el-table-column>
                <el-table-column prop="" label="操作" width="100" :align="'right'">
                    <template #default="scope">
                        <el-button class="zs-link" link size="small" @click="goDetail(scope.row)">查看</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="zs-space-top-sm zs-table-page-pagination">
                <el-pagination v-model:currentPage="currentPage" v-model:page-size="curPageSize" :page-sizes="curPageSizes"
                    :small="true" :background="true" layout="total, sizes, prev, pager, next, jumper" :total="total"
                    @size-change="handleSizeChange" @current-change="handleCurrentChange" />
            </div>
        </div>
    </div>
</template>
<script setup>
import TableSearch from '@/views/Property/component/tableSearch'
import projectListApi from '@/api/Property/projectList'
import dbPublicApi from '@/api/dbPublic'
import { ref } from 'vue'
import { useStore } from 'vuex'
import { useRouter } from 'vue-router'
const router = useRouter()
let store = useStore()
const stripe = ref(true)

const menuKey = ref('901_wuye_xiangmu')
const pageKey = ref('page_903_wuyexiangmu_wuyexiangmu')

let tag = ref('')
const updateDate = ref('')
const getDate = async () => {
  await dbPublicApi.queryDataTimeApi().then((res) => {
    if (res.data.code == 200) {
      tag.value = res.data.message
      updateDate.value = res.data.data
    }
  })
}

let searchCom = ref({})
let loading = ref(false)
let tableData = ref([]) // 表格数据

// 分页
const curPageSizes = ref(store.state.uiPageSizes)
let curPageSize = ref(store.state.uiPageSizeDefault)
let currentPage = ref(1)
const total = ref(0)
const handleSizeChange = (val) => {
    curPageSize.value = val
    getList(searchCom.value.data)
}
const handleCurrentChange = (val) => {
    currentPage.value = val
    getList(searchCom.value.data)
}

const goDetail = (row) => {
    router.push({
        path: '/page/routeController/index',
        query: {
            rid: 'Property/PropertyDashBoard',
            rTitle: '物业项目详情',
            projectCode: row.project_code,
            menuKey: menuKey.value,
            pageKey: pageKey.value,
            updateDate: updateDate.value
        },
    })
}

const getList = (value) => {
    console.log(value)
    loading.value = true
    projectListApi.propertyProjectDetailApi({ ...value, pageNo: currentPage.value, pageSize: curPageSize.value }).then((res) => {
        if (res.data.code == 200) {
            loading.value = false
            tableData.value = res.data.data.childList
            total.value = res.data.data.totalCount
        }
    })
}

const search = async (value) => {
    searchCom.value = JSON.parse(JSON.stringify(value))
    loading.value = true
    tableData.value = []
    await getDate()
    getList(value.data)
}

</script>
  
  
<style scoped lang="scss"></style>